package com.nageoffer.shortlink.admin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Bean
    public LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/api/shortlink/admin/v1/**")// 需要登录的接口路径
                .excludePathPatterns("/api/shortlink/admin/v1/user/login", "/api/shortlink/admin/v1/user/register","/api/shortlink/admin/v1/user/has/**"); // 排除登录相关接口
    }
}